# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        潘炎珍  
# Name:         demo06
# Description:
# Author:       98745
# Date:         2019/5/26
#-------------------------------------------------------------------------------

import threading
from time import sleep,ctime
class My(threading.Thread):
    def __init__(self,func,args,name=''):
        super().__init__(target=func,name=name,args=args)

    def run(self):
        self._target(*self._args)

def fun(index,sec):
    print('开始执行：',index,'时间：',ctime())
    sleep(sec)
    print('结束运行',index,'时间：',ctime())

def main():
    print('开始：',ctime())
    thread1=My(fun,(10,4),'线程1')
    thread1.start()
    thread2 = My(fun,(20,2), '线程2')
    thread2.start()
    print(thread1.name)
    print(thread2.name)
    thread1.join()
    thread2.join()

    print('结束：',ctime())


if __name__ == '__main__':
    main()